package gravitationally_adjustable_physical_ball;

public class Running extends Thread{
    private Ball ball;
    private AppPanel panel;
    private int refreshingRate;
    public Running(Ball ball, AppPanel panel,int refreshingRate){
        if(ball!=null&&refreshingRate>0) {
            this.ball = ball;
            this.panel=panel;
            this.refreshingRate=refreshingRate;
        }
        else {
            System.out.println("Illegal use detected.");
        }
    }

    @Override
    public void run() {
        while (true){
            try {
                sleep(refreshingRate);
            } catch (InterruptedException e) {}
            ball.move(refreshingRate);
            panel.revalidate();
            panel.repaint();
        }
    }
}
